package cj.web.admin.dao;
/*
 *  
 *  
*/
import java.util.List;
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.PermitConfig;

/**
 * 
 * @author 
 *
 */
@DAO
public interface PermitConfigDAO{
	
	@SQL("SELECT * FROM PermitConfig WHERE deleteFlag=1 #if(:t.areaId!=-1){ AND areaId=:t.areaId } #if(:t.schoolName!=''){ AND schoolName LIKE '%##(:t.schoolName)%' } ORDER BY updateAt DESC LIMIT :t.start,:t.length ")
    List<PermitConfig> query(@SQLParam("t") PermitConfig permitConfig);
	
	@SQL("SELECT COUNT(1) FROM PermitConfig WHERE deleteFlag=1 #if(:t.areaId!=-1){ AND areaId=:t.areaId } #if(:t.schoolName!=''){ AND schoolName LIKE '%##(:t.schoolName)%' } ")
    int querySize(@SQLParam("t") PermitConfig permitConfig);
    
    @SQL("SELECT * FROM PermitConfig WHERE id=:1 ")
    PermitConfig queryById(int id);
    
    @SQL("SELECT * FROM PermitConfig WHERE areaId=:1 AND schoolId=:2 AND deleteFlag=1")
    List<PermitConfig> queryListById(int areaId,int schoolId);
    
    @SQL("SELECT * FROM PermitConfig WHERE deleteFlag=1 ")
    List<PermitConfig> queryAll();
    
    @SQL("INSERT INTO PermitConfig (areaId,areaCode,areaName,schoolId,schoolCode,schoolName,schoolAddress,schoolNum,roomNo,seatNo,sequence,deleteFlag,createAt,createUser,updateAt,updateUser) VALUES (:t.areaId,:t.areaCode,:t.areaName,:t.schoolId,:t.schoolCode,:t.schoolName,:t.schoolAddress,:t.schoolNum,:t.roomNo,:t.seatNo,:t.sequence,1,now(),:t.createUser,now(),:t.updateUser) ")
    void create(@SQLParam("t") PermitConfig permitConfig);
	
	@SQL("UPDATE PermitConfig SET areaId=:t.areaId,areaCode=:t.areaCode,areaName=:t.areaName,schoolId=:t.schoolId,schoolCode=:t.schoolCode,schoolName=:t.schoolName,schoolAddress=:t.schoolAddress,schoolNum=:t.schoolNum,roomNo=:t.roomNo,seatNo=:t.seatNo,sequence=:t.sequence,updateAt=now(),updateUser=:t.updateUser WHERE id=:t.id ")
    void update(@SQLParam("t") PermitConfig permitConfig);
    
    @SQL("DELETE FROM PermitConfig WHERE id=:1 ")
    void deleteById(int id);
}